package de.gameduell.framework.gui.animation {
	import flash.events.EventDispatcher;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import fl.transitions.TweenEvent;	

	/**
	 * @author sdur
	 * A DummyTween is a delay for tween animation.
	 */
	public class DummyTween extends EventDispatcher implements Tweenable {
		
		private var _timer:Timer;
		
		/*
		 * @param delay in milliseconds
		 */
		public function DummyTween(delay:Number){
			_timer = new Timer(delay);
			_timer.addEventListener(TimerEvent.TIMER, onTimerComplete);	
			TweenManager.getInstance().add(this);
		}
		
		/*
		 * start the Timer
		 */
		public function start():void {
			_timer.start();
		}
		
		/*
		 * stop the Timer
		 */
		public function stop():void {
			_timer.stop();
		}
		
		/*
		 * dispatch a motion_finish event if the time is up
		 */		
		private function onTimerComplete(event:TimerEvent):void{
			_timer.stop();
			dispatchEvent(new TweenEvent(TweenEvent.MOTION_FINISH,_timer.delay,0));
		}
		
		public function get isPlaying():Boolean {
			return _timer.running;
		}
	}
}
